package com.hhit.zhgd.service.impl

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.hhit.zhgd.dao.RoleMapper
import com.hhit.zhgd.domain.entity.Role
import com.hhit.zhgd.service.RoleService
import com.hhit.zhgd.utils.strToIntArr
import org.springframework.stereotype.Service

@Service("roleService")
class RoleServiceImpl : ServiceImpl<RoleMapper, Role>(), RoleService {
    override fun getAll(params: HashMap<String, *>): List<Role> {
        return this.baseMapper.getAll(params)
    }

    override fun getList(page: Page<Role>, params: HashMap<String, Any?>): Page<HashMap<String, Any?>> {
        return this.baseMapper.getList(page, params)
    }

    override fun checkRole(role: String): Boolean? {
        val params = HashMap<String, Any>()
        params["root"] = 1
        params["role_ids"] = role.strToIntArr(",")
        val list = this.baseMapper.getAll(params)
        return list.isNotEmpty()
    }


}